---
description: Learn how to import remote code into your browser extension even in MV3.
---

# Importing Remote Code

Plasmo automatically bundles all import statements that point to a remote resource using the `https` protocol in build time. This is essential to work with [the remote code restriction in Manifest V3](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-overview/#remotely-hosted-code).

Adding the [Google Analytics 4](https://developers.google.com/analytics/devguides/collection/ga4) tracking code into our popup is as simple as:

```tsx
import "https://www.googletagmanager.com/gtag/js?id=XXXXXX"
```

The code above is not clean due to the presence of the tracking ID. However, since Plasmo parses the import statement, we can use [environment variables](./env) inside the import. Define the tracking ID in a `.env.local` file:

```
PLASMO_PUBLIC_GTAG_ID=XXXXXX
```

Then, use it in your import by prefixing a `$` before its name:

```tsx
import "https://www.googletagmanager.com/gtag/js?id=$PLASMO_PUBLIC_GTAG_ID"
```

See [with-google-analytics](https://github.com/PlasmoHQ/examples/tree/main/with-google-analytics)
